﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LIMS.Model;
using LIMS.BLL;

namespace LIMS.Web
{
    public partial class AdmStuManage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                AspNetPager1.RecordCount = BLL.StudentManager.SearchStudent(null).Count;
                rpStudent.DataSource = BLL.CommonPager<Students>.GetTSourceByPager(StudentManager.SearchStudent(null),AspNetPager1.PageSize,1);
                rpStudent.DataBind();
            }
        }

        protected void btnAddAdmin_Click(object sender, EventArgs e)
        {
            Response.Redirect("./AdminStuAdd.aspx");
        }

        protected void btnFind_Click(object sender, EventArgs e)
        {
            Model.Students stu = new Model.Students() { stuName = txtStudentName.Value.Trim() };
            rpStudent.DataSource = BLL.CommonPager<Students>.GetTSourceByPager(StudentManager.SearchStudent(stu),
               AspNetPager1.PageSize, 1);
            rpStudent.DataBind();
        }
        protected void btnFlushAdmin_Click(object sender, EventArgs e)
        {
            rpStudent.DataSource = StudentManager.SearchStudent(null);
            rpStudent.DataBind();
        }
        /// <summary>
        /// 根据班级ID获取班级名称
        /// </summary>
        /// <param name="classID"></param>
        /// <returns></returns>
        protected String GetGradeNameByID(String classID)
        {
            return StudentManager.GetClassIDAndNo()[Int32.Parse(classID)];
        }

        protected void rpStudent_ItemCommand(object source, RepeaterCommandEventArgs e)
        {

        }

        protected void rpStudent_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {

        }
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            rpStudent.DataSource = BLL.CommonPager<Model.Students>.GetTSourceByPager(BLL.StudentManager.SearchStudent(null),
                AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex);
            rpStudent.DataBind();
        }


    }
}